# $Id: Rakefile 4 2007-09-27 09:38:28Z dinko.srkoc $

require 'rake/testtask'
require 'rake/gempackagetask'
require 'rubygems'

verfile = File.join(File.dirname(__FILE__), 'lib', 'genus.rb')
GVERSION = File.read(verfile)[/^GENUS_VERSION\s*=\s*(['"])(\d\.\d\.\d)\1/, 2]

task :default => [ :build_gem ]

spec = Gem::Specification.new do |s|
  s.name = 'genus'
  s.version  = GVERSION
  s.platform = Gem::Platform::RUBY
  s.summary  = 'Generator of Java persistence descriptors.'
  s.description =<<-END_DESC
    Gives you a simple way to generate Java persistence descriptors
    (e.g. persistence.xml), so you won't ever have to copy and paste
    it again. It supports all major open source JPA providers and
    throws in support for Hibernate cfg.xml files for your convenience.
  END_DESC
  
  s.files  = FileList['{bin,lib,doc,test,example}/**/*'].to_a #'exclude('rdoc').to_a
  s.require_path = 'lib'
#  s.autorequire  = ''
#  s.test_file    = ''
  s.bindir = 'bin'
  s.executables = ['gen']
  s.default_executable = 'gen'  
  
  s.has_rdoc = true
  s.extra_rdoc_files = %w{README LICENSE-BSD doc/examples.rdoc doc/descriptor-format.rdoc}
  s.rdoc_options << '--main' << 'README' << '--charset' << 'utf8' << '--title' << 'Genus - Java Persistence Descriptor Generator'

  s.author   = 'Dinko Srkoc'
  s.email    = 'dinko.srkoc@helix.hr'
  s.homepage = 'http://gluino.blogspot.com'
end

Rake::GemPackageTask.new(spec) do |pkg|
  pkg.need_tar = true
end

desc "Runs all the tests"
Rake::TestTask.new do |test|
  test.libs << 'test'
  test.test_files = %w{ test/ts_all.rb }
  test.verbose    = true
end

desc "Builds a new Genus gem"
task :build_gem do
  Rake::Task["pkg/genus-#{GVERSION}.gem".to_sym].invoke
end